package com.zjsystem.zjsy.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.zjsystem.zjsy.dto.ZjInstruct;
import com.zjsystem.zjsy.request.InstructRequest;
import com.zjsystem.zjsy.result.Result;
import com.zjsystem.zjsy.service.ZjInstructService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wyf
 * @since 2024-07-11
 */
@Slf4j
@Api("调控记录")
@RestController
@RequestMapping("/zjsy/zjInstruct")
public class ZjInstructController {

    @Resource
    private ZjInstructService instructService;

    @ApiOperation("指令新增or修改")
    @PostMapping("/saveOrUpdateInstruct")
    public Result saveOrUpdateInstruct(@RequestBody InstructRequest request) {
        try {
            instructService.saveInstruct(request);
            return Result.ok("指令新增成功");
        } catch (Exception e) {
            log.error("新增指令异常：{}", e.getMessage());
            return Result.fail().message("新增任务异常");
        }
    }

//    @ApiOperation("指令列表展示+模糊")
//    @PostMapping("/instructList")
//    public Result instructList(@RequestBody InstructRequest request){
//        try {
//            IPage<ZjInstruct> page = instructService.pageList(request);
//            return Result.ok(page);
//        } catch (Exception e) {
//            log.error("列表展示异常:{}", e.getMessage());
//            return Result.fail().message("列表展示异常");
//        }
//    }
}

